from fastapi import APIRouter, Depends, HTTPException, status
from fastapi.responses import JSONResponse
from sqlalchemy.orm import Session
from databases import sessionlocal
from auth import get_current_user
users = APIRouter()


def get_db():
    db = sessionlocal()
    try:
        yield db
    finally:
        db.close()
@users.get("/me")
async def read_me(current_user: dict = Depends(get_current_user), db: Session = Depends(get_db)):
    return JSONResponse(status_code=status.HTTP_200_OK, content={"message": "用户信息获取成功", "data": current_user})
